<?php

namespace App\Admin\Extensions\Column;

use Encore\Admin\Admin;
use Encore\Admin\Grid\Displayers\AbstractDisplayer;

class Modalinfo extends AbstractDisplayer
{
    public function display($placement = 'left')
    {
        if (!$this->value) {
            return '';
        }

        if (mb_strlen($this->value)>10) {
            $showText = mb_substr($this->value,0,10).'...';
        } else {
            return $this->value;
        }

        return <<<EOT
        $showText
<a style="cursor:pointer;" data-toggle="modal" data-target="#Modalinfo{$this->getKey()}">
  <small>查看更多</small> 
</a>

<!-- Modal -->
<div class="modal fade" id="Modalinfo{$this->getKey()}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">信息</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        {$this->value}
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
<!--        <button type="button" class="btn btn-primary">Save changes</button>-->
      </div>
    </div>
  </div>
</div>

EOT;

    }
}
